package com.aiyige.page.my.download.adapter;

import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.FragmentStatePagerAdapter;

import com.aiyige.R;
import com.aiyige.page.my.download.DownloadDataPage;
import com.aiyige.utils.StringUtils;

import java.util.LinkedList;
import java.util.List;

public class MyDownloadPagerAdapter extends FragmentPagerAdapter {

    public List<DownloadDataPage> downloadDataPageList;

    public MyDownloadPagerAdapter(FragmentManager fm) {
        super(fm);
        downloadDataPageList = new LinkedList<>();
    }

    public void setDownloadDataPageList(List<DownloadDataPage> downloadDataPageList) {
        this.downloadDataPageList = downloadDataPageList;
    }

    @Override
    public Fragment getItem(int position) {
        return downloadDataPageList.get(position);
    }

    @Override
    public int getCount() {
        return downloadDataPageList.size();
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        switch (downloadDataPageList.get(position).getFilterType()) {
            case DownloadDataPage.FILTER_TYPE_LEARN_VIDEO:
                return StringUtils.getString(R.string.learn_video);
            case DownloadDataPage.FILTER_TYPE_NORMAL_VIDEO:
                return StringUtils.getString(R.string.video);
            case DownloadDataPage.FILTER_TYPE_LOCAL_VIDEO:
                return StringUtils.getString(R.string.local_video);
            default:
                return "";
        }
    }
}
